package ppp.hhh.the.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@ControllerAdvice
public class CustomerBusinessExceptionHandler {
    @ResponseBody
    @ExceptionHandler(BusinessException.class)
    public Map<String, Object> handleException(BusinessException ex){
        Map<String, Object> map=new HashMap<>();
        map.put("code", ex.getCode());
        map.put("msg", ex.getMessage());
        return map;
    }
}
